package com.huawei;

import java.io.*;
import java.lang.*;

/**
 * Description: HJ69 矩阵乘法
 *
 * @author weiruibai.vendor
 * Date: 2022/8/31 09:44
 */
public class HJ69 {

    /**
     * 输入：
     * 1 2 3
     * 3 2 1
     * =====
     * 1 2
     * 2 1
     * 3 3
     * 输出：
     * 14 13
     * 10 11
     *
     * @param args
     * @throws IOException
     */
    public static void main(String[] args) throws IOException {

        int[][] A = new int[][]{
                {1, 2, 3},
                {3, 2, 1},
        };
        int[][] B = new int[][]{
                {1, 2},
                {2, 1},
                {3, 3},
        };
        int x = A.length;// 行
        int y = A[0].length;// 列
        int z = B[0].length;// B列   
        int[][] ans = new int[x][z];
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < z; j++) {
                for (int k = 0; k < y; k++) {
                    ans[i][j] += A[i][k] * B[k][j];
                }
            }
        }
        System.out.println(ans);

    }

    private static void input() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int x = Integer.parseInt(br.readLine());
        int y = Integer.parseInt(br.readLine());
        int z = Integer.parseInt(br.readLine());
        int[][] A = new int[x][y];
        int[][] B = new int[y][z];
        String[] str;
        for (int i = 0; i < x; i++) {
            str = br.readLine().split(" ");
            for (int j = 0; j < y; j++) {
                A[i][j] = Integer.parseInt(str[j]);
            }
        }
        for (int i = 0; i < y; i++) {
            str = br.readLine().split(" ");
            for (int j = 0; j < z; j++) {
                B[i][j] = Integer.parseInt(str[j]);
            }
        }
        int[][] ans = new int[x][z];
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < z; j++) {
                for (int k = 0; k < y; k++) {
                    ans[i][j] += A[i][k] * B[k][j];
                }
            }
        }
        for (int i = 0; i < ans.length; i++) {
            for (int j = 0; j < ans[0].length; j++) {
                System.out.print(ans[i][j] + " ");
            }
            System.out.println();
        }
    }
}
